﻿using System;
using System.Text;
using System.Linq;
using DevExpress.ExpressApp;
using System.ComponentModel;
using DevExpress.ExpressApp.DC;
using System.Collections.Generic;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Updating;
using DevExpress.ExpressApp.Model.Core;
using DevExpress.ExpressApp.Model.DomainLogics;
using DevExpress.ExpressApp.Model.NodeGenerators;
using DevExpress.ExpressApp.Xpo;
using DevExpress.Xpo;
using DevExpress.ExpressApp.SystemModule;
using aztall.Module.BusinessObjects;

namespace aztall.Module
{
  // For more typical usage scenarios, be sure to check out https://documentation.devexpress.com/eXpressAppFramework/clsDevExpressExpressAppModuleBasetopic.aspx.
  public sealed partial class aztallModule : ModuleBase
  {
    public aztallModule()
    {
      InitializeComponent();
      BaseObject.OidInitializationMode = OidInitializationMode.AfterConstruction;
    }
    public override IEnumerable<ModuleUpdater> GetModuleUpdaters(IObjectSpace objectSpace, Version versionFromDB)
    {
      ModuleUpdater updater = new DatabaseUpdate.Updater(objectSpace, versionFromDB);
      return new ModuleUpdater[] { updater };
    }
    public override void Setup(XafApplication application)
    {
      base.Setup(application);
      // Manage various aspects of the application UI and behavior at the module level.
    }
    public override void CustomizeTypesInfo(ITypesInfo typesInfo)
    {
      base.CustomizeTypesInfo(typesInfo);
      CalculatedPersistentAliasHelper.CustomizeTypesInfo(typesInfo);
      typesInfo.FindTypeInfo(typeof(XPObject)).KeyMember.AddAttribute(new BrowsableAttribute(false));
    }
    public override void AddGeneratorUpdaters(ModelNodesGeneratorUpdaters updaters)
    {
      base.AddGeneratorUpdaters(updaters);
      //updaters.Add(new DomainFilterUpdater());
    }
    //private class DomainFilterUpdater : ModelNodesGeneratorUpdater<ModelListViewFiltersGenerator>
    //{
    //	public override void UpdateNode(ModelNode node)
    //	{
    //IModelListViewFilters filtersNode = (IModelListViewFilters)node;
    //if (((IModelListView)filtersNode.Parent).ModelClass.TypeInfo.Type.IsSubclassOf(typeof(DomainObject)))
    //{
    //	IModelListViewFilterItem domainFilter =
    //			filtersNode.AddNode<IModelListViewFilterItem>("DomainFilter");
    //	domainFilter.Criteria = "Domain.Oid = '" + Env.CurrentDomainOid + "'";
    //	domainFilter.Index = 1;
    //	domainFilter.Caption = "Domain Filter";
    //	domainFilter.Description = "Filter on current domain";

    //	filtersNode.CurrentFilter = domainFilter;

    //}
    //}
    //}
  }
}
